﻿<?php 
require '../../frame/base.php';
//$res = $Db->table('shop')->field('name')->where('shopid',2)->fetchSql()->find();
$_REQUEST['page'] = !empty($_REQUEST['page'])?$_REQUEST['page']:'';
$_REQUEST['pagesize'] = !empty($_REQUEST['pagesize'])?$_REQUEST['pagesize']:'';

// 分页
if($_REQUEST['page']!="" && $_REQUEST['pagesize']!=""){
	$de=$_REQUEST['page']*$_REQUEST['pagesize'];
	$size=$_REQUEST['pagesize'];
}else{
	$de=0;
	$size=20;
}
// 分页 end

$tag = !empty($_REQUEST['tag'])?$_REQUEST['tag']:null;
$aid = !empty($_REQUEST['aid'])?$_REQUEST['aid']:null;
if($tag=='more'){
	$article=$Db->table('article')->field('id,title,image,created_at')->order('id desc')->limit($de,$size)->select();
}else if($tag=='detail'){
	$article=$Db->table('article')->field('id,title,image,content,created_at')->where('id',$aid)->order('id desc')->limit($de,$size)->select();
}else{
	$article=$Db->table('article')->field('title')->order('id desc')->limit(5)->select();
}
$ary = array('data'=>$article,'code'=>200,'msg'=>'成功');
echo json_encode($ary);